//
//  XJHomeTagCollectionViewCell.m
//  XinJiangMall
//
//  Created by Tzyang on 2018/4/10.
//  Copyright © 2018年 Tzyang. All rights reserved.
//

#import "XJHomeTagCollectionViewCell.h"

#import "HomeTagsModel.h"
#import <UIImageView+WebCache.h>
#import "UIView+DCRolling.h"
#import "UIImage+ColorImage.h"

@interface XJHomeTagCollectionViewCell ()

/* imageView */
@property (strong , nonatomic)UIImageView *gridImageView;
/* gridLabel */
@property (strong , nonatomic)UILabel *gridLabel;


@end

@implementation XJHomeTagCollectionViewCell

#pragma mark - Intial
- (instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    if (self) {
        
        [self setUpUI];
        
    }
    return self;
}

- (void)setUpUI{
    self.backgroundColor = WHITE_COLOR;
    
    _gridImageView = [[UIImageView alloc] init];
    _gridImageView.layer.masksToBounds = YES;
    _gridImageView.layer.cornerRadius = UI_IS_IPHONE5?19:24;
    _gridImageView.contentMode = UIViewContentModeScaleAspectFill;
    [self addSubview:_gridImageView];
    
    _gridLabel = [[UILabel alloc] init];
    _gridLabel.font = XJFONTSET_R(12);
    _gridLabel.textColor = XJCOLOR_RGB(17, 17, 17);
    _gridLabel.textAlignment = NSTextAlignmentCenter;
    [self addSubview:_gridLabel];
    
}

- (void)layoutSubviews{
    [super layoutSubviews];
    
    [_gridImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        [make.top.mas_equalTo(self)setOffset:XJMargin];
        if (UI_IS_IPHONE5) {
            make.size.mas_equalTo(CGSizeMake(38, 38));
        }else{
            make.size.mas_equalTo(CGSizeMake(48, 48));
        }
        make.centerX.mas_equalTo(self);
    }];
    
    [_gridLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        [make.top.mas_equalTo(_gridImageView.mas_bottom)setOffset:10];
    }];
    
}

#pragma mark - Setter Getter Methods
- (void)setHtModel:(HomeTagsModel *)htModel{
    _htModel = htModel;
    
    _gridLabel.text = htModel.name;
    
    [_gridImageView sd_setImageWithURL:[NSURL URLWithString:htModel.icon] placeholderImage:[UIImage imageWithColor:XJCOLOR_RGB(221, 221, 221)]];
   
}



@end
